import { _decorator, Component, find, Node, tween } from 'cc';
import { BaseGuideCommand } from './BaseGuideCommand';
const { ccclass, property } = _decorator;

/**
 * 基础移动命令
 */
@ccclass('BaseMoveCommand')
export class BaseMoveCommand extends BaseGuideCommand {
    /**
     * 公用 移动方法
     */
    protected async run(): Promise<void> {
        console.log("【BaseMoveCommand】执行...");
        // 获取当前的小时、分钟和秒数
        const now = new Date();
        const hours = now.getHours();
        const minutes = now.getMinutes();
        const seconds = now.getSeconds();

        // 打印当前时间（时:分:秒）
        console.log(`输出当前时间： ${hours}:${minutes}:${seconds}`);
        
        return new Promise<void>((resolve) => {
            let targetNode = find(this.stepConfig.path);
            this.curTween = tween(this.guideNode)
                .to(this.stepConfig.duration, { position: targetNode.position })
                .call(() => resolve())
                .start();

            setTimeout(() => resolve(), this.stepConfig.waitForSecond*1000);
        });
    }
}


